﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Copa_do_Mundo_2014
{
    public partial class Editar : Form
    {
        String[,] compras;
        int aux;
        public Editar(String[,] compras )
        {
            InitializeComponent();
            this.compras = compras;
        }

        private void Editar_Load(object sender, EventArgs e)
        {

        }

        private void btnprocurar_Click(object sender, EventArgs e)
        {
            txtnome.Text = "";
            txtrg.Text = "";
            lblsucesso.Text = "";
            for (int i = 0; i < compras.GetLength(0); i++)
            {
                if (compras[i, 3] == txtcod.Text)
                {
                    txtnome.Text = compras[i, 0];
                    txtrg.Text = compras[i, 1];
                    aux = i;
                }
            } 
        }

        private void btneditar_Click(object sender, EventArgs e)
        {
            compras[aux, 0] = txtnome.Text;
            compras[aux, 1] = txtrg.Text;
            txtnome.Text = "";
            txtrg.Text = "";
            txtcod.Text = "";
            lblsucesso.Text = "Editado";

        }

        private void btncancelar_Click(object sender, EventArgs e)
        {
            Aviso aviso = new Aviso(this);
            aviso.Show();
            
        }

        private void btnvoltar_Click(object sender, EventArgs e)
        {
            Principal principal = new Principal(compras);
            principal.Show();
            this.Hide();
        }

        private void Editar_FormClosing(object sender, FormClosingEventArgs e)
        {
            Application.Exit();
        }

        public void remover()
        {
            compras[aux, 0] = "";
            compras[aux, 1] = "";
            compras[aux, 2] = "";
            compras[aux, 3] = "";
            txtnome.Text = "";
            txtrg.Text = "";
            txtcod.Text = "";
        }

    }
}
